#include "Fire.h"
#include "RSManager.h"
#include "Box.h"
#include <d3dx9.h>
#include "Object.h"
#include "Sprite.h"

#define V_MOVE_FIRE 1.4f
Fire::Fire(Box* box): Object(box,ObjEnemy_DYNAMID)
{
}


Fire::~Fire(void)
{
}

void Fire::init()
{
	this->_sprite = RSManager::getInstance()->getSprite(FIRE);
	box1 = new Box(D3DXVECTOR2(_box->_position),_sprite->getRenderSize(),D3DXVECTOR2(0,0));
	box2 = new Box(D3DXVECTOR2(_box->getRight() - 32,_box->_position.y),_sprite->getRenderSize(),D3DXVECTOR2(0,0));
	dx1 = 1;
	dx2 = -1;
}

void Fire::update()
{
	if(box1->getLeft() < _box->getLeft() || box1->getRight() > _box->getRight())
	{
		dx1 *= -1.0f;
	}
	if(box2->getLeft() < _box->getLeft() || box2->getRight() > _box->getRight())
	{
		dx2 *= -1.0f;
	}
	box1->_position.x += dx1 * V_MOVE_FIRE;
	box2->_position.x += dx2 * V_MOVE_FIRE;

}

void Fire::render()
{
	_sprite->Render(box1->_position);
	_sprite->Render(box2->_position);
}

Box* Fire::getCollisionBox()
{
	return _box;
}
